package com.itwn.portal.config;


import com.itwn.portal.Interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/comicDetail").setViewName("comicDetail");
        registry.addViewController("/search").setViewName("search");
        registry.addViewController("/rankList").setViewName("rankList");
        registry.addViewController("/person").setViewName("person");
        registry.addViewController("/personCenter").setViewName("personCenter");
        registry.addViewController("/paySet").setViewName("paySet");
        registry.addViewController("/alreadyBuy").setViewName("alreadyBuy");
        registry.addViewController("/myBookcase").setViewName("myBookcase");
        registry.addViewController("/votingRecord").setViewName("votingRecord");
        registry.addViewController("/read").setViewName("Read");
        registry.addViewController("/readPage").setViewName("ReadPage");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInterceptor()).addPathPatterns("/person");
    }
}
